package net.sareweb.acab.entity.manager;

import net.sareweb.acab.entity.User;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Name("userManager")
@Scope(ScopeType.CONVERSATION)
public class UserManager extends CommonManager<User> {
	
	
	private final String query="from User where login=:login";
	
	public boolean existsLoginName(String login){
		try{
			User result = (User)entityManager.createQuery(query).setParameter("login",login).getSingleResult();
			return true;
		}
		catch(Exception e){
			return false;
		}	
	}
	
	public User findByLoginName(String login){
		try{
			User result = (User)entityManager.createQuery(query).setParameter("login",login).getSingleResult();
			return result;
		}
		catch(Exception e){
			return null;
		}	
	}

}
